package com.boot.proofing.controller.base;/**
 * @description
 * @autor xbwu on 2018/7/2.
 */

import com.boot.core.common.base.ResultWapper;
import com.boot.core.common.util.LocaleMessageSource;
import com.boot.proofing.common.util.FileUtil;
import com.boot.proofing.mpweb.base.entity.User;
import com.boot.proofing.mpweb.base.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 上传控制器
 * @author xbwu
 * @create 2018-07-02 
 **/
@RestController
public class UploadController extends BaseController {

    /**
     * 国际化消息
     */
    @Autowired
    private LocaleMessageSource i18n;

    @Autowired
    IUserService userService;

    /**
     * 上传用户头像
     * @param multipartFile
     * @return
     */
    @PostMapping("/file/upload/headPortraits")
    public ResultWapper uploadheadPortraits(@RequestParam("editor-file") MultipartFile multipartFile){

        ResultWapper rw = null;
        User currentUser = userService.getCurrentUser();
        String uploadPath = FileUtil.getUserFilePath(currentUser);
        return uploadFile(multipartFile,uploadPath);
    }
}
